import { fileURLToPath, URL } from 'node:url'
//工具类，将路径提取出来：将请求交个tomcat处理
//代理服务器
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))//别名
    }
  },
  server: {
    proxy: {//代理路径
      '/api': {
        target: 'http://localhost:8080',//交个tomcat处理
        secure: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),//路径重写，将api换成空串
      }
    }
  }
})
